﻿using System.Collections;
using System.Diagnostics;
using UnityEngine;
using Random = System.Random;

namespace UFrame
{
    public class UnityTool
    {
        public static Random mRandom = new Random();
        private static bool mCancelShake = false;

        public static IEnumerator ShakeCamera(Transform transform, float shakeStrength = 0.1f, float rate = 8,
            float shakeTime = 0.3f)
        {
            float t = 0;
            float speed = 1 / shakeTime;
            Vector3 orgPosition = transform.localPosition;
            while (t < 1 && !mCancelShake)
            {
                t += Time.deltaTime * speed;
                transform.position = orgPosition + new Vector3(Mathf.Sin(rate * t), Mathf.Cos(rate * t), 0) *
                    Mathf.Lerp(shakeStrength, 0, t);
                yield return null;
            }

            mCancelShake = false;
            transform.position = orgPosition;
        }


        [Conditional("PL_Debug"), Conditional("UNITY_EDITOR")]
        public static void BeginSample(string s)
        {
            //if(Profiler.enabled)
            //Profiler.BeginSample(s);
        }

        [Conditional("PL_Debug"), Conditional("UNITY_EDITOR")]
        public static void EndSample()
        {
            //if (Profiler.enabled)
            //Profiler.EndSample();
        }
    }


    public static class UnityStaticMethod
    {



    }
}